package com.zoran.study.spring.validation.constraint;

import com.zoran.study.spring.validation.validator.CellPhoneValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Cell phone validation annotation.
 *
 * @author Winter Gao
 */
@Documented
@Retention(RUNTIME)
@Target({FIELD, PARAMETER})
@Constraint(validatedBy = {CellPhoneValidator.class})
public @interface CellPhone {

    String message() default "{geerong.validation.constraints.CellPhone.message}";

    /**
     * Cell phone number pattern.
     */
    String pattern() default "^\\+?0?(86)?[ ]*1\\d{10}$";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

}
